let logger = require('log4js').getLogger("default");
const User = require('../../../models/user/userModel.js')
const { itemNotFound } = require('../../../utils/itemNotFound.js')
const findUserByName = async function (user_name = {}) {
    return new Promise((resolve, reject) => {
        User.findOne({ 'user_name': user_name, status: "1" },
            async (err, item) => {
                try {
                    await itemNotFound(err, item, '用户不存在')
                    resolve(item)
                } catch (error) {
                    logger.error(error)
                    reject(error)
                }
            })
    });
};

module.exports = { findUserByName }